# -*- coding: utf-8 -*-
from datetime import timedelta
from utils.operators.spark_submit import SparkSubmitOperator

from jms.dwd.tms.dwd_tmsnew_shipment_union_base_dt import jms_dwd__dwd_tmsnew_shipment_union_base_dt
from jms.dwd.tms.dwd_tmsnew_shipment_stop_union_base_dt import jms_dwd__dwd_tmsnew_shipment_stop_union_base_dt
from jms.dwd.tab.dwd_tab_barscan_loading_base_dt import jms_dwd__dwd_tab_barscan_loading_base_dt
from jms.dwd.tab.dwd_tab_barscan_unloading_base_dt import jms_dwd__dwd_tab_barscan_unloading_base_dt
from jms.time_sensor.time_after_04_00 import time_after_04_00

jms_dm__dm_shipment_stop_billcode_detail_dt  = SparkSubmitOperator(
    task_id='jms_dm__dm_shipment_stop_billcode_detail_dt',
    email=['guoruiling@jtexpress.com','yl_bigdata@yl-scm.com'],
    name='jms_dm__dm_shipment_stop_billcode_detail_dt_{{ execution_date | cst_ds }}',
    pool_slots=2,
    retries=1,
    driver_memory='8G',
    executor_memory='8G',
    executor_cores=4,
    num_executors=20,
    yarn_queue='pro',
    conf={'spark.dynamicAllocation.enabled': 'true',  # 动态资源开启
          'spark.shuffle.service.enabled': 'true',  # 动态资源 Shuffle 服务开启
          'spark.dynamicAllocation.maxExecutors': 50,  # 动态资源最大扩容 Executor 数
          'spark.dynamicAllocation.cachedExecutorIdleTimeout': 60,  # 动态资源自动释放闲置 Executor 的超时时间(s)
          'spark.sql.sources.partitionOverwriteMode': 'dynamic',  # 允许删改已存在的分区
          'spark.executor.memoryOverhead': '4G',  # 堆外内存
          'spark.default.parallelism': 600,
          'spark.sql.shuffle.partitions': 600
          },
    jars='hdfs:///scheduler/jms/spark/grl/dm_shipment_stop_billcode_detail_dt/common-1.0-SNAPSHOT.jar',  # 依赖 jar 包
    java_class='com.yunlu.bigdata.jobs.export.ExportFIOShipmentStopBillcodeDetailDate',  # spark 主类
    application='hdfs:///scheduler/jms/spark/grl/dm_shipment_stop_billcode_detail_dt/original-jobs-1.0-SNAPSHOT.jar',
    # spark jar 包
    application_args=['{{ execution_date | cst_ds }}'],
    #execution_timeout=timedelta(hours=3)
    #excel平均时长:8分54秒
    #execution_timeout = timedelta(minutes=15)
    #excel平均时长:8分54秒
    execution_timeout = timedelta(minutes=30)
)

jms_dm__dm_shipment_stop_billcode_detail_dt  << [
    jms_dwd__dwd_tmsnew_shipment_union_base_dt,
    jms_dwd__dwd_tmsnew_shipment_stop_union_base_dt,
    jms_dwd__dwd_tab_barscan_loading_base_dt,
    jms_dwd__dwd_tab_barscan_unloading_base_dt,
    time_after_04_00
]
 